import request from '@/utils/request'

import _request from '@/services/baseService'

function getToken() {
  const token = localStorage.getItem('business-token')
  return token
}
export async function Login(params) {
  return request('/hzsx/user/login', {
    method: 'POST',
    data: params,
    headers: {
      token: getToken()
    }
  })
}
export async function getFakeCaptcha(mobile) {
  return request(`/hzsx/api/login/captcha?mobile=${mobile}`)
}

export async function homeData(params) {
  return request('/hzsx/ope/order/opeOrderStatistics', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function queryOrderReport(params) {
  return request('/hzsx/ope/order/queryOrderReport', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 数据看板-首页上方及左下方-指标数量以及较昨日同比增长率
export async function queryDataViewCountIndexOne(data) {
  return request('/hzsx/dataViewCount/indexOne', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}
export async function queryDataViewCountIndexOneEither(data) {
  return request('/hzsx/dataViewCount/indexOneEither', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}

// 查询数据看板-首页左下方-每日审核通过率、逾期率统计
export async function queryDataViewCountIndexTwo(data) {
  return request('/hzsx/dataViewCount/indexTwo', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}

// 查询数据看板-首页右下方-租赁商品占比
export async function queryDataViewCountIndexThree(data) {
  return request('/hzsx/product/indexThree', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}

// 租赁记录统计
export async function queryRentCount(data) {
  return request('/hzsx/dataViewCount/rentRecordCount', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}
// 数据汇总表
export async function queryScheduleRecordCount(data) {
  return request('/hzsx/dataViewCount/scheduleRecordCount', {
    method: 'POST',
    data,
    headers: { token: getToken() }
  })
}
//数据汇总表---数据汇总表导出
export async function exportScheduleRecord(data) {
  return request('/hzsx/dataViewCount/exportScheduleRecord', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    },
    responseType: 'blob'
  })
}
// 即将到期订单 - 导出功能
export async function exportToLocal(data) {
  return request('/hzsx/business/order/excelOpeGoingOverDueOrdersByCondition', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    },
    responseType: 'blob'
  })
}
//租赁记录列表导出
export async function exportRent(data) {
  return request('/hzsx/dataViewCount/exportRentRecord', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    },
    responseType: 'blob'
  })
}
//数据统计---会员列表导出
export async function exportUserListBaseInfo(data) {
  return request('/hzsx/user/exportUserListBaseInfo', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    },
    responseType: 'blob'
  })
}
//订单列表客勤导出
export async function exportQueryOrderByConditionExt(data) {
  return request('/hzsx/business/order/exportQueryOrderByConditionExt', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    },
    responseType: 'blob'
  })
}
export default {
  register: data => {
    return _request(`/hzsx/user/register`, data)
  },
  restPassword: data => {
    return _request(`/hzsx/user/restPassword`, data)
  },
  sendValidateCode: data => {
    return _request(`/hzsx/user/sendValidateCode`, data, 'get')
  }
}
